package controllers.administrator;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import services.AuctionService;
import services.BidService;
import services.CommentService;
import services.CustomerService;
import services.GalleryService;
import services.PaintingService;
import controllers.AbstractController;
import domain.Auction;
import domain.Bid;
import domain.Comment;
import domain.Customer;
import domain.Gallery;
import domain.Painting;

@Controller
@RequestMapping("/dashboard/admin")
public class DashboardAdministratorController extends AbstractController {
	
	// Supporting services ----------------------------------------------------
	
	@Autowired
	private BidService bidService;
	
	@Autowired
	private GalleryService galleryService;
	
	@Autowired
	private CustomerService customerService;
	
	@Autowired
	private AuctionService auctionService;
	
	@Autowired
	private PaintingService paintingService;
	
	@Autowired
	private CommentService commentService;

	// Constructors -----------------------------------------------------------
	
	public DashboardAdministratorController() {
		super();
	}
		
	// Listing ---------------------------------------------------------------		

	@RequestMapping("/show")
	public ModelAndView list() {
		ModelAndView result;
		Collection<Bid> bid = bidService.findHighestBid();
		Collection<Customer> customerP = customerService.findCustomerWithMorePaintings();
		Collection<Gallery> gallery = galleryService.findMostExpensiveGallery();
		Collection<Auction> auction = auctionService.findAuctionWithMoreBids();
		Collection<Customer> customerC = customerService.findCustomerWithMoreComments();
		Collection<Painting> painting = paintingService.findPaintingWithMoreComments();
		Collection<Comment> comment = commentService.findCommentWithMoreResponses();
		
		result = new ModelAndView("dashboard/show");
		
		result.addObject("bid", bid);
		result.addObject("customerP", customerP);
		result.addObject("gallery", gallery);
		result.addObject("auction", auction);
		result.addObject("customerC", customerC);
		result.addObject("painting", painting);
		result.addObject("comment", comment);
		return result;
	}

	
}
